﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using easyList.Tools;

namespace easyList.Entities
{
    class ArchiveObject
    {

        public List<FileObject> contentList { get; set; }
      

        internal void addFileObject(FileObject currentFile)
        {
            if (this.contentList == null)
            {
                this.contentList = new List<FileObject>();
            }
            this.contentList.Add(currentFile);
        }


        public void addListToArchive(List<FileObject> newList)
        {
            if (newList == null)
            {
                return;
            }
            //create new contentlist if there is no (first add)
            if (this.contentList == null)
            {
                this.contentList = new List<FileObject>();
            }

            List<FileObject> tmpList = new List<FileObject>();

            foreach (FileObject currFile in this.contentList)
            {
                tmpList.Add(currFile);
            }

            foreach (FileObject currFile in newList)
            {
                tmpList.Add(currFile);
            }

            this.contentList = tmpList;

            SortTool.sortArchiveByFileName(this);
        }


        public void addArchiveToArchive(ArchiveObject archive)
        {
            if (archive == null)
            {
                return;
            }

            if (archive.contentList == null)
            {
                return;
            }

            addListToArchive(archive.contentList);
        }



    }
}
